package com.mlk.engUser.controller;

import com.mlk.core.component.page.Pager;
import com.mlk.engUser.service.EngUserService;
import com.mlk.engUser.vo.EngUserRemainVO;
import com.mlk.engUser.vo.EngUserVO;
import com.mlk.score.po.EngInScore;
import com.mlk.score.service.EngInScoreService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 客户列表查询
 */
@Controller
@RequestMapping("/eng/user")
public class EngUserController {
    @Resource
    private EngUserService engUserService;

    @Resource
    private EngInScoreService engInScoreService;

    /**
     * 返回业务统计首页
     * @return
     */
    @RequestMapping("index")
    public String index(){
        return "engUser/clientList";
    }

    /**
     * 客户列表查询
     */
    @RequestMapping("clientList")
    @ResponseBody
    public Pager clientList(EngUserVO user){
        return this.engUserService.clientList(user);
    }


    // 查询用户的余额的信息
    @RequestMapping("userRemain")
    public String userRemain(String openId, Model model){
        model.addAttribute("openId",openId);
        return "engUser/userRemain";
    }

    /**
     * 用户余额列表
     * @return
     */
    @RequestMapping("userRemainList")
    @ResponseBody
    public Pager userRemainList(EngUserRemainVO vo){
        return this.engUserService.userRemainList(vo);
    }

    // 查询用户的积分的信息
    @RequestMapping("userScore")
    public String userScore(String openId, Model model){
        model.addAttribute("openId",openId);
        return "engUser/userScore";
    }

    /**
     * 用户积分列表
     * @return
     */
    @RequestMapping("userScoreList")
    @ResponseBody
    public Pager userScoreList(EngInScore vo){
        return this.engInScoreService.findTotalScoreDetail(vo);
    }

    /**
     * 用户数据导出
     */
    @RequestMapping("export")
    @ResponseBody
    public void export(){
        this.engUserService.export();
    }
}
